<template>
  <j-modal
    :title="title"
    :fullscreen="true"
    :width="1600"
    :visible="visible"
    :maskClosable="false"
    @close="close"
    destroyOnClose
  >
    <a-tabs v-model="activeKey" @change="changeTabs">
      <a-tab-pane key="unit_prc" tab="责任成本单价"></a-tab-pane>
      <a-tab-pane key="last_ex_tax_amt" tab="分包合同清单价"></a-tab-pane>
      <a-tab-pane key="guid_prc" tab="分包指导价"></a-tab-pane>
      <a-tab-pane key="eav_unit_prc" tab="T验工计价单价"></a-tab-pane>
    </a-tabs>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      @change="handleTableChange"
      class="antableClass"
    ></a-table>
  </j-modal>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { columns1 } from './checkColumns'
import { getAction } from '@/api/manage'
export default {
  name: 'ProjectQualityDetails',
  mixins: [JeecgListMixin],
  data() {
    return {
      queryParam: {
        id: ''
      },
      record: {},
      visible: false,
      title: '详情列表',
      columns: columns1(),
      dataSource: [],
      url: {
        list: '/sjmx/queryUnitPrc'
      },
      UrlList: {
        unit_prc: '/sjmx/queryUnitPrc', // 责任成本
        last_ex_tax_amt: '/sjmx/querylastExTaxAmt', // 分包合同清单价
        guid_prc: '/sjmx/queryGuidPrc', // 指导价
        eav_unit_prc: '/sjmx/queryEav' // 验工计价单价
      },
      activeKey: 'unit_prc',
      disableMixinCreated: true
    }
  },
  methods: {
    close() {
      this.visible = false
      this.record = {}
      this.queryParam = {}
    },
    changeTabs(key) {
      this.getdata(key)
    },
    check(record, key) {
      this.record = Object.assign({}, record)
      this.getdata(key)
      this.visible = true
    },
    getdata(key) {
      this.activeKey = key
      this.url.list = this.UrlList[key] // 获取url
      switch (key) {
        case 'unit_prc':
          this.queryParam.id = this.record.unit_prc_id
          break
        case 'last_ex_tax_amt':
          this.queryParam.id = this.record.con_id
          break
        case 'guid_prc':
          this.queryParam.id = this.record.con_id
          break
        case 'eav_unit_prc':
          this.queryParam.id = this.record.eav_id
          break
      }
      this.loadData(1)
    },
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      // 加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams() // 查询条件
      this.loading = true
      // this.dataSource=[]
      getAction(this.url.list, params).then(res => {
        if (res.success) {
          // update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          let data = res.result.records || res.result
          this.dataSource = data.map(item => {
            item['con_num'] = this.record.con_num
            item['con_nm'] = this.record.con_nm
            return item
          })
          if (res.result.total) {
            this.ipagination.total = res.result.total
          } else {
            this.ipagination.total = 0
          }
          // update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
        } else {
          this.$message.error(res.message)
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
      })
    }
  }
}
</script>

<style lang="less" scoped>
@import '~@assets/less/tableTheme.less';
</style>
